import {View} from '@tarojs/components'

import {AtButton} from "taro-ui";
import Taro from "@tarojs/taro";
import './index.scss'
import GlobalFooter from "../../components/global-footer";
import questions from '../../data/question.json'
import questionResults from '../../data/question_result.json'
import {getBestQuestionResult} from "../../utils/getTestResultUtils";

/**
 * 主页
 */
export default () => {
  const storageSync = Taro.getStorageSync('answerList');
  let result = getBestQuestionResult(storageSync, questions, questionResults);
  const questionResult = result;

  return <View className='result-page'>
    <View className='at-article__h1 title'>
      {questionResult.resultName}
    </View>
    <View className='at-article__h2 sub-title'>
      {questionResult.resultDesc}
    </View>
    <AtButton type='primary' className='enter-btn' circle
              onClick={() => Taro.reLaunch({
                url: '/pages/index/index'
              })}
    >返回主页</AtButton>
    <GlobalFooter></GlobalFooter>
  </View>
}

